<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <button onclick="routerWay()">页面路由跳转方法</button>
    <button onclick="hashWay()">hash跳转方法</button>
    <button onclick="backWay()">backWay方法</button>
    <button onclick="pushState()">pushState方法</button>
    <button onclick="replaceState()">replaceState方法</button>
</body>
<script>
    let routerWay = () => {
        window.location.href = "http://www.baidu.com";
    }
    let hashWay = () => {
        window.location = "#hash"
        //  Hash变化时触发
        window.onhashchange = () => {
            console.log('current hash: ', window.location.hash)
        }
    }
    let backWay = () => {
        history.back();
        history.go(-1);
    }
    let pushState = () => {
        history.pushState(null, null, "?path2")
    }
    // window.onpopstate = function(){
    //     console.log(window.location.href);
    // }
</script>
</html>